package com.siyuanren.gcocp.dto;

import com.siyuanren.gcocp.common.config.PublicConfig;
import com.siyuanren.gcocp.entity.WxCourse;
import com.siyuanren.gcocp.enumm.CourseType;
import com.siyuanren.gcocp.util.ObjectUtil;
import lombok.Getter;
import lombok.Setter;

import java.util.Date;

/**
 * Created by   anxing
 * Project_name gcocp-parent
 * Path         com.siyuanren.gcocp.dto
 * Date         2018/6/12
 * Time         11:45
 * Description
 */
@Getter
@Setter
public class CourseDetailDTO extends WxCourse {
    /**
     * 课程开课期数
     */
    private Integer courseNumber;
    private String teacherName;
    private String teacherImg;
    private Date startTime;
    private Date registerLastTime;
    /**
     * 优惠卷金额
     */
    private int voucher_fee;

    /**
     * 是否已购买
     */
    private int payState;

    /**
     *   课程订购数量
     */
    private int orderCount;

    /**
     * 加入群学习的群二维码
     */
    private String groupQrcodeImg;
    /**
     * 最终购买金额
     * @return
     */
    public int getTotalFee() {
        int totalFee = ObjectUtil.isEmpty(super.getFavourableFee()) ?
                super.getCourseFee() : super.getFavourableFee();
        totalFee = totalFee - voucher_fee;
        if (totalFee <= 0) {
            totalFee = 0;
        }
        return totalFee;
    }

    public String getTeacherImg() {
        return PublicConfig.RESOURCE_URL + teacherImg;
    }

    public String getCourseImg() {
        return PublicConfig.RESOURCE_URL + super.getCourseImg();
    }
    public String getCourseItemImg() {
        return PublicConfig.RESOURCE_URL + super.getCourseItemImg();
    }

    public String getInviteImg() {
        return PublicConfig.RESOURCE_URL + super.getInviteImg();
    }

    public String getGroupQrcodeImg() {
        return PublicConfig.RESOURCE_URL + groupQrcodeImg;
    }

    public String getCourseTypeStr() {
        return CourseType.getDesc(super.getCourseType());
    }
}
